import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {UnitInfoVO, UnitInfoForm, UnitInfoQuery, GenUnitDocQuery} from '@/api/busi/unitInfo/types';

/**
 * 查询单位基础信息列表
 * @param query
 * @returns {*}
 */

export const listUnitInfo = (query?: UnitInfoQuery): AxiosPromise<UnitInfoVO[]> => {
  return request({
    url: '/busi/unitInfo/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询单位基础信息列表
 * @param query
 * @returns {*}
 */

export const queryUnitList = (query?: UnitInfoQuery): AxiosPromise<UnitInfoVO[]> => {
  return request({
    url: '/busi/unitInfo/queryUnitList',
    method: 'get',
    params: query
  });
};
export const genUnitDoc = (query?: GenUnitDocQuery): AxiosPromise<number> => {
  return request({
    url: '/busi/unitInfo/genUnitDoc',
    method: 'get',
    params: query
  });
};
export const genPublicDoc = (query?: GenUnitDocQuery): AxiosPromise<number> => {
  return request({
    url: '/busi/unitInfo/genPublicDoc',
    method: 'get',
    params: query
  });
};

/**
 * 查询单位基础信息详细
 * @param id
 */
export const getUnitInfo = (id: string | number): AxiosPromise<UnitInfoVO> => {
  return request({
    url: '/busi/unitInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增单位基础信息
 * @param data
 */
export const addUnitInfo = (data: UnitInfoForm) => {
  return request({
    url: '/busi/unitInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改单位基础信息
 * @param data
 */
export const updateUnitInfo = (data: UnitInfoForm) => {
  return request({
    url: '/busi/unitInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除单位基础信息
 * @param id
 */
export const delUnitInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/busi/unitInfo/' + id,
    method: 'delete'
  });
};
/**
 * 获取识别后的单位信息
 * @param imageId 上传的图片id
 */
export const getBizLicense = (imageId?: string | number): AxiosPromise<UnitInfoVO> => {
  return request({
    url: '/busi/unitInfo/getBizLicense/' + imageId,
    method: 'get'
  });
};
/**
 * 获取识别后的单位信息
 * @param imageId 上传的图片id
 */
export const getIdCard = (imageId?: string | number): AxiosPromise<UnitInfoVO> => {
  return request({
    url: '/busi/unitInfo/getIdCard/' + imageId,
    method: 'get'
  });
};

